Skip to content

Simple RuntimeTypeSystem DacDbi APIs#126732

Merged
rcj1 merged 3 commits intodotnet:mainfrom
rcj1:simple-rts
Apr 10, 2026
Merged

Simple RuntimeTypeSystem DacDbi APIs#126732
rcj1 merged 3 commits intodotnet:mainfrom
rcj1:simple-rts

Conversation

@rcj1
Copy link
Copy Markdown
Contributor

@rcj1 rcj1 commented Apr 9, 2026

Implementing DacDbi APIs HasTypeParams, GetTypeHandle and GetThreadStaticAddress that use and require minimal modifications to the RuntimeTypeSystem cDAC contract.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds minimal RuntimeTypeSystem contract surface and corresponding Legacy DacDbi/SOS implementations to support a few simple DacDbi APIs (HasTypeParams, GetTypeHandle, GetThreadStaticAddress) using cDAC data.

Changes:

  • Implement DacDbiImpl.HasTypeParams, GetTypeHandle, and GetThreadStaticAddress against cDAC contracts (with DEBUG cross-validation vs legacy DAC when available).
  • Extend RuntimeTypeSystem contract with ContainsGenericVariables and GetFieldDescThreadStaticAddress, plus supporting MethodTable flag plumbing.
  • Consolidate ECMA token helpers into EcmaMetadataUtils and update docs/HResults accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs Replaces local metadata token enum usage with shared EcmaMetadataUtils token helpers.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs Implements the three requested DacDbi APIs via cDAC contracts with DEBUG parity checks.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodTableFlags_1.cs Adds ContainsGenericVariables MethodTable flag bit support.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/EcmaMetadataUtils.cs Makes token utilities publicly reusable (token type enum + mask).
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs Implements ContainsGenericVariables and adds thread-static address computation API.
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/CorDbHResults.cs Adds HRESULT constant for “class not loaded”.
src/native/managed/cdac/docs/design/datacontracts/RuntimeTypeSystem.md Documents the new RuntimeTypeSystem APIs and static/thread-static address helpers.

Copy link
Copy Markdown
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot had some good feedback but other than that it looked good to me

Copy link
Copy Markdown
Member

@max-charlamb max-charlamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. It'd be good to have some simple unit/dump tests

Copilot AI review requested due to automatic review settings April 10, 2026 21:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/RuntimeTypeSystem_1.cs:1902

  • GetFieldDescStaticOrThreadStaticAddress uses _target.Contracts.EcmaMetadata.GetMetadata(moduleHandle)!, but IEcmaMetadata.GetMetadata is nullable. In dump/minidump scenarios this can be null and would turn into a NullReferenceException rather than returning TargetPointer.Null (or a controlled HRESULT). Consider handling the null case explicitly before calling GetFieldDefinition.
        MetadataReader mdReader = _target.Contracts.EcmaMetadata.GetMetadata(moduleHandle)!;
        uint token = ((IRuntimeTypeSystem)this).GetFieldDescMemberDef(fieldDescPointer);
        FieldDefinitionHandle fieldHandle = (FieldDefinitionHandle)MetadataTokens.Handle((int)token);
        FieldDefinition fieldDef = mdReader.GetFieldDefinition(fieldHandle);

@rcj1 rcj1 merged commit adcbacf into dotnet:main Apr 10, 2026
62 of 65 checks passed
@rcj1 rcj1 deleted the simple-rts branch April 10, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants